package com.caseprocessing.api;

import java.util.List;

/**
 * SiliconFlow API聊天补全请求模型
 */
public class ChatCompletionRequest {
    
    private String model;
    private List<Message> messages;
    private Double temperature;
    private Integer maxTokens;
    private Double topP;
    private Double frequencyPenalty;
    private Double presencePenalty;
    private List<String> stop;
    private Boolean stream;
    
    public ChatCompletionRequest() {}
    
    public String getModel() {
        return model;
    }
    
    public void setModel(String model) {
        this.model = model;
    }
    
    public List<Message> getMessages() {
        return messages;
    }
    
    public void setMessages(List<Message> messages) {
        this.messages = messages;
    }
    
    public Double getTemperature() {
        return temperature;
    }
    
    public void setTemperature(Double temperature) {
        this.temperature = temperature;
    }
    
    public Integer getMaxTokens() {
        return maxTokens;
    }
    
    public void setMaxTokens(Integer maxTokens) {
        this.maxTokens = maxTokens;
    }
    
    public Double getTopP() {
        return topP;
    }
    
    public void setTopP(Double topP) {
        this.topP = topP;
    }
    
    public Double getFrequencyPenalty() {
        return frequencyPenalty;
    }
    
    public void setFrequencyPenalty(Double frequencyPenalty) {
        this.frequencyPenalty = frequencyPenalty;
    }
    
    public Double getPresencePenalty() {
        return presencePenalty;
    }
    
    public void setPresencePenalty(Double presencePenalty) {
        this.presencePenalty = presencePenalty;
    }
    
    public List<String> getStop() {
        return stop;
    }
    
    public void setStop(List<String> stop) {
        this.stop = stop;
    }
    
    public Boolean getStream() {
        return stream;
    }
    
    public void setStream(Boolean stream) {
        this.stream = stream;
    }
    
    /**
     * 请求构建器
     */
    public static RequestBuilder builder() {
        return new RequestBuilder();
    }
    
    public static class RequestBuilder {
        private String model;
        private List<Message> messages;
        private Double temperature;
        private Integer maxTokens;
        private Double topP;
        private Double frequencyPenalty;
        private Double presencePenalty;
        private List<String> stop;
        private Boolean stream;
        
        public RequestBuilder model(String model) {
            this.model = model;
            return this;
        }
        
        public RequestBuilder messages(List<Message> messages) {
            this.messages = messages;
            return this;
        }
        
        public RequestBuilder temperature(Double temperature) {
            this.temperature = temperature;
            return this;
        }
        
        public RequestBuilder maxTokens(Integer maxTokens) {
            this.maxTokens = maxTokens;
            return this;
        }
        
        public RequestBuilder topP(Double topP) {
            this.topP = topP;
            return this;
        }
        
        public RequestBuilder frequencyPenalty(Double frequencyPenalty) {
            this.frequencyPenalty = frequencyPenalty;
            return this;
        }
        
        public RequestBuilder presencePenalty(Double presencePenalty) {
            this.presencePenalty = presencePenalty;
            return this;
        }
        
        public RequestBuilder stop(List<String> stop) {
            this.stop = stop;
            return this;
        }
        
        public RequestBuilder stream(Boolean stream) {
            this.stream = stream;
            return this;
        }
        
        public ChatCompletionRequest build() {
            ChatCompletionRequest request = new ChatCompletionRequest();
            request.setModel(model);
            request.setMessages(messages);
            request.setTemperature(temperature);
            request.setMaxTokens(maxTokens);
            request.setTopP(topP);
            request.setFrequencyPenalty(frequencyPenalty);
            request.setPresencePenalty(presencePenalty);
            request.setStop(stop);
            request.setStream(stream);
            return request;
        }
    }
    
    @Override
    public String toString() {
        return "ChatCompletionRequest{" +
                "model='" + model + '\'' +
                ", messages=" + messages +
                ", temperature=" + temperature +
                ", maxTokens=" + maxTokens +
                ", topP=" + topP +
                ", frequencyPenalty=" + frequencyPenalty +
                ", presencePenalty=" + presencePenalty +
                ", stop=" + stop +
                ", stream=" + stream +
                '}';
    }
}